﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Xml.Linq;

namespace ObjectOuster
{
    public delegate void CurrentThemeChangedDelegate();
    public static class GameConfig
    {
        private static SoundEffectsManager soundEffects = new SoundEffectsManager();
        public static SoundEffectsManager SoundEffects
        {
            get
            {
                return soundEffects;
            }
        }
        private static MusicManager music = new MusicManager();
        public static MusicManager Music
        {
            get
            {
                return music;
            }
        }
        private static event CurrentThemeChangedDelegate onCurrentThemeChanged;
        private static ThemeTable themeTable = null;
        private static int currentTheme = 0;
        public static int CurrentTheme
        {
            get
            {
                return currentTheme;
            }
            set
            {
                if (value >= 0 && value < Themes.Count && value!=currentTheme)
                {
                    currentTheme = value;
                    if (onCurrentThemeChanged != null)
                    {
                        onCurrentThemeChanged();
                    }
                }
            }
        }
        public static event CurrentThemeChangedDelegate OnCurrentThemeChanged
        {
            add
            {
                onCurrentThemeChanged += value;
            }
            remove
            {
                onCurrentThemeChanged -= value;
            }
        }
        public static ThemeTable Themes
        {
            get
            {
                return themeTable;
            }
        }
        public static void Load()
        {
            XDocument document = XDocument.Load("config/themes.xml");
            themeTable = new ThemeTable(document.Element("themes"));
        }
        public static void Save()
        {
        }
        static GameConfig()
        {
            Load();
        }
    }
}
